export default {
  computed: {
    // 当前书本页的热区
    currentHotmap: function () {
      if (this.pages[this.currentPagesNum] && this.pages[this.currentPagesNum].hotmap) {
        return this.pages[this.currentPagesNum].hotmap
      } else {
        return []
      }
    },
    // 当前鼠标的样式
    cursorStyle: function () {
      let url = ''
      switch (this.currentButton) {
        case 'isShowSelect':
          url = 'pen'
          break
        case 'isRubber':
          url = 'rubberButton'
          break
        case 'isNarrow':
          // url = 'narrowButton'
          break
        case 'isEnlarge':
          // url = 'enlargeButton'
          break
        case 'isDrag':
          url = 'dragButton'
          break
        case 'dragMove':
          url = 'mouseButton'
          break
        case 'isShowChartBg':
          url = 'chartButton'
          break
        case 'isShowDiceBg':
          url = 'diceButton'
          break
        case 'isShowNumberBg':
          url = 'numberButton'
          break
      }
      if (url) {
        return `cursor: url('${require(`../assets/imgs/ico/${url}.ico`)}') ${url == 'pen' ? '16 32' : '16 16'}, auto`
      } else {
        return ''
      }
    }
  },
  methods: {
    // 弹框
    doHandleBtn (type) {
      this.currentButton = type === this.currentButton ? '' : type
      this.currentBgButton = ''
      // this.isEnlarge = false
      switch (type) {
        case 'isShowSelect':
          // 颜色画板
          this.disSelectAll()
          this.optHandler('line')
          break
        case 'isRubber':
          // 橡皮檫
          this.disSelectAll()
          this.optHandler('clear')
          break
        case 'isNarrow':
          // 缩小
          this.stopAll()
          break
        case 'isEnlarge':
          this.stopAll()
          let src = `case${this.bookId}/P${this.currentPagesNum}.png`
          this.gotoPreview(src)
          break
        case 'isDrag':
          // 拖拽
          this.stopAll()
          this.disSelectAll()
          break
        case 'isStopAll':
          // 还原
          this.stopAll()
          this.allowSelectAll()
          break
        case 'dragMove': {
          // 选择任何工具前进行一些重置工作
          // 禁用画笔模式
          // this.canvas.isDrawingMode = false;
          // 禁止图形选择编辑
          this.canvas.isDrawingMode = false;
          this.allowSelectAll()
          break
        }
        case 'isShowChartBg':
          this.allowSelectAll()
          break
        case 'isShowDiceBg':
          this.allowSelectAll()
          break
        case 'isShowNumberBg':
          this.allowSelectAll()
          break
      }
    },
  }
}